import React, { forwardRef, useRef } from 'react'

export default function App() {
    const text = useRef(1111)
    return (
        <div>
            <button onClick={() => { 
                text.current.value = ""
                text.current.focus()
            }}>失去焦点</button>
            <Child ref={text} />
        </div>
    )
}
const Child = forwardRef((props, ref) => {
    return <div style={{background: 'red'}}>
        <input type="text" ref={ref} defaultValue={ref.current}/>
    </div>
})
